﻿namespace EyeOpen.Validation
{
    /// <summary>
    /// Validates a string, the value is valid if string is not <c>null</c>, empty or spaces only.
    /// </summary>
    public class RequiredValidator : Validator<string>
    {
        /// <summary>
        /// Gets the validation message.
        /// </summary>
        /// <value>The validation message.</value>
        public override string ValidationMessage
        {
            get
            {
                CheckValidationIsCalled();

                return "Value is required.";
            }
        }

        /// <summary>
        /// Determines whether the specified string is not <c>null</c>, empty or spaces only.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>
        /// <c>true</c> if the specified value is valid; otherwise, <c>false</c>.
        /// </returns>
        public override bool IsValid(string value)
        {
            ValidationCalled();

            return !string.IsNullOrWhiteSpace(value);
        }
    }
}